/*
 * @lc app=leetcode.cn id=98 lang=cpp
 *
 * [98] 验证二叉搜索树
 */

// @lc code=start
/**
 * Definition for a binary tree node.
 * struct TreeNode {
 *     int val;
 *     TreeNode *left;
 *     TreeNode *right;
 *     TreeNode() : val(0), left(nullptr), right(nullptr) {}
 *     TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}
 *     TreeNode(int x, TreeNode *left, TreeNode *right) : val(x), left(left), right(right) {}
 * };
 */
class Solution {
public:
//平衡二叉树中序遍历严格递增
void inOrder(TreeNode* root,vector<int>& ans){
        if(root == nullptr) 
            return ;
        inOrder(root->left,ans);
        ans.emplace_back(root->val);
        inOrder(root->right,ans);
    }
    bool isValidBST(TreeNode* root) {
        vector<int> help;
        inOrder(root,help);
        for(int i=1;i<help.size();i++){
            if(help[i]<=help[i-1]) 
                return false;
        }
        return true;
    }
};
// @lc code=end

